package com.ljfiction.book.activitys;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.widget.LinearLayoutManager;
import android.view.View;
import android.widget.ImageView;

import com.androidkun.xtablayout.XTabLayout;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.google.gson.Gson;
import com.ljfiction.book.Baner.PepperhavestBean;
import com.ljfiction.book.R;
import com.ljfiction.book.adapter.IndentDetailAdapter;
import com.ljfiction.book.adapter.PeppeerhavestAdapter;
import com.ljfiction.book.fragment.MydanmuFragment;
import com.ljfiction.book.fragment.MyshupingFragment;
import com.ljfiction.book.fragment.pepper.JinjiaoFragment;
import com.ljfiction.book.fragment.pepper.PepperFragment;
import com.ljfiction.book.fragment.pepper.XiaomijiaoFragment;
import com.ljfiction.book.fragment.pepper.XmjBean;
import com.ljfiction.book.http.HttpManager;
import com.ljfiction.book.tools.SettingManager;
import com.lzy.okhttputils.OkHttpUtils;
import com.lzy.okhttputils.callback.StringCallback;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.listener.OnRefreshLoadMoreListener;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import okhttp3.Call;
import okhttp3.Response;

public class PepperharvestActivity extends BaseActivity {

    @BindView(R.id.back_peperhavest)
    ImageView backPeperhavest;
    @BindView(R.id.pepper_xtablayout)
    XTabLayout pepperXtablayout;
    @BindView(R.id.pepper_viewpager)
    ViewPager pepperViewpager;

    private PepperFragment pepperFragment;
    private XiaomijiaoFragment xiaomijiaoFragment;
    private JinjiaoFragment jinjiaoFragment;
    private ArrayList<Fragment> fragments = new ArrayList<>();
    private String tabTitles[] = new String[]{"辣椒", "小米椒", "金椒"};
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_pepperharvest);
        ButterKnife.bind(this);
        intview();
    }



    private void intview() {
        pepperFragment = new PepperFragment();
        xiaomijiaoFragment =new XiaomijiaoFragment();
        jinjiaoFragment=new JinjiaoFragment();
        fragments.add(pepperFragment);
        fragments.add(xiaomijiaoFragment);
        fragments.add(jinjiaoFragment);
        IndentDetailAdapter adapter = new IndentDetailAdapter(getSupportFragmentManager(), tabTitles, fragments);
        pepperViewpager.setAdapter(adapter);
        pepperViewpager.setOffscreenPageLimit(3);
        pepperViewpager.setOverScrollMode(View.OVER_SCROLL_NEVER);
        pepperXtablayout.setupWithViewPager(pepperViewpager);

    }

    @OnClick(R.id.back_peperhavest)
    public void onViewClicked() {
        goBack();
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == 8 && resultCode == 8) {
            pepperFragment.refresh();
        }
    }
}
